import id.co.gomobile.assessment.Preference;
import id.co.gomobile.assessment.Role;
import id.co.gomobile.assessment.Test;
import id.co.gomobile.assessment.User;

class BootStrap {
	
	def authenticateService
	
	def init = { servletContext ->
		/*
		// init roles
		def adminRole = new Role([name: "ROLE_ADMIN", description: "Administrator"])
		def userRole = new Role([name: "ROLE_USER", description: "Standard user"])
		
		adminRole.save(flush: true)
		userRole.save(flush: true)
		
		// init admin user
		// login info
		def adminUser = new User()
		adminUser.username = "administrator"
		adminUser.password = authenticateService.encodePassword("secret")
		adminUser.email = "save.nx@gmail.com"
		// profile
		adminUser.profile.fullname = "Administrator"
		adminUser.profile.birthdate = new Date()
		adminUser.profile.gender = "Male"
		adminUser.profile.phone = "0"
		adminUser.save(flush: true)
		
		// default role
		adminUser.addToRoles(Role.findByName("ROLE_ADMIN"))
		adminUser.addToRoles(Role.findByName("ROLE_USER"))
		
		def test = new Test([name: "GoMobile Recruitment Program"])
		test.preference = new Preference()
		test.preference.test = test
		test.save(flush: true)
		*/
	}
	
	def destroy = {
	}

} 